<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="标识汇">
    <meta name="keyword" content="标识汇">
    <title>标识汇-注册</title>
    <link href="${relativePath}/static/css/common.css" type="text/css" rel="stylesheet">
    <link href="${relativePath}/static/css/login.css" type="text/css" rel="stylesheet">
  </head>
  <body>
    <div class="layout login-container">
      <header>
        <div class="logo fl"><img src="${relativePath}/static/imgs/logo.png"><i></i><span>新用户注册</span></div>
        <div class="right-nav fr">
          <ul>
            <li><a class="phonecall" href="#">热线电话：400-100-2848</a></li>
          </ul>
        </div>
      </header>
    </div>
    <div class="banner registBox">
      <div class="registInner">
        <div class="topReg"><span class="newreg">新用户注册</span><span class="alLogin fr">
            已有账号，
            <a href="login.html">请登陆</a></span></div>
        <div class="registBt">
          <div class="haveNum">
            <label class="hasNum active">有邀请码</label>
            <label class="noNum">无邀请码</label>
          </div>
          <form class="logBox login-box" name="regist" id="regist">
            <div class="fl_wrap">
              <input class="nice_name" type="text" name="nice_name" placeholder="邀请码">
            </div>
            <div class="fl_wrap">
              <input class="phone_num" type="text" name="phone_num" placeholder="请输入手机号">
            </div>
            <div class="fl_wrap">
              <input class="message_num" type="text" name="message_num" placeholder="请输入短信验证码">
              <input class="num_code" type="button" value="获取验证码" id="sendBtn">
            </div>
            <div class="fl_wrap">
              <input class="password" id="password" type="password" name="password" placeholder="设置密码" required="true">
            </div>
            <div class="fl_wrap">
              <input class="password_pre" name="password_pre" type="password" placeholder="确认密码" required="true">
            </div><span class="agree">
              <label>
                <input class="agreeMe" type="checkbox" name="agreeMe" required>&nbsp;我已阅读并同意
                <a href="javascript:;"> 《使用条款及协议》</a>
              </label></span><a class="regBtn" href="javascript:;">注 册</a>
          </form>
          <form class="logBox login-box" name="regist" id="noregist">
            <div class="fl_wrap">
              <input class="phone_num" type="text" name="phone_num" placeholder="请输入手机号">
            </div>
            <div class="fl_wrap">
              <input class="message_num" type="text" name="message_num" placeholder="请输入短信验证码">
              <input class="num_code" type="button" value="获取验证码" id="sendBtnone">
            </div>
            <div class="fl_wrap">
              <input class="message_num" id="yyzz" type="text" name="message_num" placeholder=""><a class="href" id="lastHref" href="javascript:;">请点击选择营业执照</a>
              <input class="num_code upone" type="button" value="点击上传">
              <input class="photofile yyzzFile" id="files" type="file" name="files[]"><a class="resource resourceone" href="javascript:;">参考</a>
            </div>
            <div class="fl_wrap">
              <input class="message_num" id="sqs" type="text" name="message_num" placeholder=""><a class="href" id="lastHref2" href="javascript:;">请点击选择授权书</a>
              <input class="num_code uptwo" type="button" value="点击上传">
              <input class="photofile sqsFile" id="files_2" type="file" name="files_2[]"><a class="resource download" href="javascript:;">下载</a><a class="resource resourcetwo" href="javascript:;">参考</a>
            </div>
            <div class="fl_wrap">
              <input class="password" id="passwordone" type="password" name="passwordone" placeholder="设置密码" required="true">
            </div>
            <div class="fl_wrap">
              <input class="password_pre" name="password_pre" type="password" placeholder="确认密码" required="true">
            </div><span class="agree">
              <label>
                <input class="agreeMe" type="checkbox" name="agreeMe" required>&nbsp;我已阅读并同意
                <a href="javascript:;"> 《使用条款及协议》</a>
              </label></span><a class="regBtn" href="javascript:;">注 册</a>
            <div id="yycard"><img src="${relativePath}/static/imgs/yyzz.png"></div>
            <div id="sqscard"><img src="${relativePath}/static/imgs/sqs.jpg"></div>
          </form>
        </div>
      </div>
    </div>
    <div class="footer">
      <div class="footer-inner">
        <div class="left">
          <p>标识汇官网|成品材料|定制加工|需求中心|社区资讯|工作ERP|办公OA微单系统|供销存</p>
          <p>@copy;2015标识汇  豫ICP备15032515</p>
          <p>版权所有：标识汇网络技术有限公司</p>
        </div>
        <div class="code">
          <div class="code_1"><img src="${relativePath}/static/imgs/code_1.png">
            <p>下载手机标识汇</p>
          </div>
          <div class="code_2"><img src="${relativePath}/static/imgs/code_2.png">
            <p>关注微信公众号</p>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
<script type="text/javascript" src="${relativePath}/static/js/jquery.min.js"></script>
<script type="text/javascript" src="${relativePath}/static/js/libs/jquery.cookie.js"></script>
<script type="text/javascript" src="${relativePath}/static/js/common.js"></script>
<script type="text/javascript" src="${relativePath}/static/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="${relativePath}/static/js/messages_zh.js"></script>
<script src="${relativePath}/static/js/libs/layer/layer.js"></script>
<script>
  $(function(){
  	//var shopIp = "http://testweb.biaoshi360.cn"
  	$(".haveNum label").click(function() {
  		$(this).addClass("active").siblings().removeClass("active");
  		$(".registBt .logBox").hide().eq($(this).index()).show();
  	})
  	// 手机号码验证
  	jQuery.validator.addMethod("isMobile", function(value, element) {
  		var length = value.length;
  		var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
  		return this.optional(element) || (length == 11 && mobile.test(value));
  	}, "请正确填写您的手机号码");
  	//- 发送验证码
  	var countdown=60;
  	function settime(obj) {
  	    if (countdown == 0) {
  	        obj.removeAttribute("disabled");    
  	        obj.value="获取验证码";
  	        countdown = 60;
  	        return;
  	    } else {
  	        obj.setAttribute("disabled", true);
  	        obj.value="重新发送(" + countdown + ")";
  	        countdown--;
  	    }
  	setTimeout(function() {
  	    settime(obj) }
  	    ,1000)
  	}
  	
  	$("#sendBtn").click(function() {
  		layer.msg("请输入手机号")
  	})
  	$("#sendBtnone").click(function(){
  		layer.msg("请输入手机号")
  	})
  	var validator = $("#regist").validate({
  			rules: {
  				nice_name:{
  					required:true
  				},
  				recommender_num:{
  					required : true,
  					minlength : 11,
  					// 自定义方法：校验手机号在数据库中是否存在
  					// checkPhoneExist : true,
  		    		isMobile : true
  				},
  				phone_num:{
  					required:true,
  					isMobile:true
  				},
  				message_num:{
  					required:true,
  				},
  				password:{
  					required: true
  				},
  				password_pre:{
  					required: true,
  					equalTo: "#password"
  				}
  			},
  			messages : {
  				nice_name:{
  					required : "请输入真实姓名"
  				},
  		        recommender_num : {
  					required : "请输入推荐人号码"
  		        },
  		        phone_num:{
  		        	required:'请输入手机号'
  		        },
  		        message_num:{
  		        	required:'请输入验证码'
  		        },
  		        password:{
  		        	required:'请输入密码',
  		        	minlength: 8
  		        },
  		        password_pre:{
  		        	required:'请确认密码',
  		        	equalTo: "两次密码输入不一致"
  		        }
  		    },
  		    errorPlacement: function(error, element) {  
  			    error.appendTo(element.closest(".fl_wrap"));
  				if(element.is("[name='agreeMe']")) {
  					element.closest("span.agree").find("label.error").remove();
  					element.closest("span.agree").append(error);
  				}
  			}
  		});
  	
  	//- 点击发送验证码
  	$(".num_code").click(function(){
  		var phoneNum = $(".phone_num").val();
  		var _this = this;
  		if(phoneNum == ""){
  			return false;
  		}else{
  			$.ajax({
  				url:shopIp+"/Utils/sendCaptcha",
  				type:"post",
  				data:{
  					os:"web",
  					phone:phoneNum,
  					register:1
  				},
  				dataType: "jsonp",
  			}).done(function(data){
  				if(data.status == "200"){
  					settime(_this);
  				}else{
  					layer.msg(data.msg);
  				}
  			})
  		}
  		
  	})
  
  	//- 点击注册
  	$("#regist .regBtn").click(function(){
  		var recommender_num = $(".recommender_num").val();
  		var phoneNum = $(".phone_num").val();
  		var message_num = $(".message_num").val();
  		var password = $(".password").val();
  		var password_pre = $(".password_pre").val();
  		if(validator.form()) {
  			//验证通过
  			$.ajax({
  				url:shopIp+"/Account/register",
  				data:{
  					os:"web",
  					phone:phoneNum,
  					nice_name:$(".nice_name").val(),
  					inviterPhone:recommender_num,
  					smsCode:message_num,
  					password:password,
  					repassword:password_pre,
  					register:1
  				},
  				dataType: "jsonp",
  			}).done(function(data){
  				if(data.status == "200"){
  					window.location.href = "login.html";
  				}else{
  					layer.msg(data.msg);
  				}
  			})
  		}
  	})
  	//- 点击下载
  	$.getJSON(shopIp+'/utils/download?callback=?&os=web',function(data){
  		$(".download").attr("href",data.data);
  	})
  	//- 点击参考营业执照
  	$(".resourceone").click(function() {
  		layer.open({
  		  type: 1,
  		  title: false,
  		  closeBtn: 1,
  		  area: '884px',
  		  skin: 'layui-layer-nobg', //没有背景色
  		  shadeClose: true,
  		  content: $('#yycard')
  		});
  	})
  	//- 点击参考营业执照
  	$(".resourcetwo").click(function() {
  		layer.open({
  		  type: 1,
  		  title: false,
  		  closeBtn: 1,
  		  area: '793px',
  		  skin: 'layui-layer-nobg', //没有背景色
  		  shadeClose: true,
  		  content: $('#sqscard')
  		});
  	})
  	//- 上传y营业执照及授权书
  	if (window.File && window.FileReader && window.FileList && window.Blob){
  		//Blob是计算机界通用术语之一，全称写作：BLOB (binary large object)，表示二进制大对象。
  		//全部支持
  		function handleFileSelect(evt,ele,ele2) {
  			console.log(evt.target.files)
  			var files = evt.target.files, f = files[0];
  			var formdata=new FormData(ele[0]);
  			if (!/image\/\w+/.test(f.type)){
  				layer.msg("请确保文件为图像类型");
  				return false;
  			}
  			var reader = new FileReader();
  			reader.onload = (function(theFile) {
  				return function(e) {
  					//- var show_pic = document.getElementById("show_pic");
  					//- show_pic.src = e.target.result;
  					//console.log(e.target.result);
  				};
  			})(f);
  			reader.readAsDataURL(f);
  			$.ajax({
  				url:shopIp+"/Utils/uploadFiles?userToken="+token,
  				type:"post",
  				data:formdata,
  				dataType:"json",
  				async:false,
  				cache:false,
  				contentType:false,
  				processData:false,
  				success:function(data) {
  					//console.log(data.data.path);
  					ele2.html("");
  					ele2.html(data.data.url);
  					ele2.attr({
  						"href":data.data.url,
  						"target":"_blank"
  					});
  					ele2.css("color","#6794c6")
  					//$(".hidden1").val(data.data.path);
  				},
  				error:function(data) {
  					//console.log(data);
  				}
  			})
  		}
  		document.getElementById('files').addEventListener('change', handleFileSelect(event,$("#noregist"),$("#lastHref")), false);
  		
  		//document.getElementById('files_2').addEventListener('change', handleFileSelect2, false);
  
  		function handleFileSelect2(evt) {
  			var files_2 = evt.target.files, f = files_2[0];
  			var formdata=new FormData($("#noregist")[0])
  			if (!/image\/\w+/.test(f.type)){
  				layer.msg("请确保文件为图像类型");
  				return false;
  			}
  			var reader = new FileReader();
  			reader.onload = (function(theFile) {
  				return function(e) {
  					//- var show_pic = document.getElementById("show_pic1");
  					//- show_pic.src = e.target.result;
  				};
  			})(f);
  			reader.readAsDataURL(f);
  			$.ajax({
  				url:shopIp+"/Utils/uploadFiles?userToken="+token,
  				type:"post",
  				data:formdata,
  				dataType:"json",
  				async:false,
  				cache:false,
  				contentType:false,
  				processData:false,
  				success:function(data) {
  					console.log(data);
  					$("#lastHref2").html(data.data.url);
  					$("#lastHref2").attr({
  						"href":data.data.url,
  						"target":"_blank"
  					});
  					$("#lastHref2").css("color","#6794c6")
  				},
  				error:function(data) {
  					console.log(data);
  				}
  			})
  
  		}
  		
  
  	}else {
  	    layer.msg('该浏览器不全部支持File APIs的功能');
  	}
  })
</script>